//
//  CALayer+Anim.m
//  InnJia
//
//  Created by pg on 16/6/20.
//  Copyright © 2016年 pg. All rights reserved.
//

#import "CALayer+Anim.h"

@implementation CALayer (Anim)

-(void)shake{
    CAKeyframeAnimation *kfa = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
    //幅度
    CGFloat s = 16;
    kfa.values = @[@(-s),@(0),@(s),@(0),@(-s),@(0),@(s),@(0)];
    //时长
    kfa.duration = .1f;
    //重复
    kfa.repeatCount = 2;
    //移除
    kfa.removedOnCompletion = YES;
    [self addAnimation:kfa forKey:@"shake"];
}

@end
